<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Goodssku extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'goodssku';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'country_id_text',
        'country_id'
    ];

    public function getCountryList()
    {
        $countryModel = new Country();
        return $countryModel->getCountryList();
    }

    public function getCountryListStringIndex()
    {
        $countryModel = new Country();
        return $countryModel->getCountryListStringIndex();
    }

    public function getCountryIdTextAttr($value,$data)
    {
        $status = $this->getCountryList();
        return $status[$data['country_id']];
    }

/*    public function getStatusTextAttr($value,$data)
    {
        $status = [-1=>'删除',0=>'禁用',1=>'正常',2=>'待审核'];
        return $status[$data['status']];
    }*/

    public function goods()
    {
        return $this->belongsTo('Goods', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

}
